﻿// -----------------------------------------------------------------------
// Copyright (c) David Kean. All rights reserved.
// -----------------------------------------------------------------------
extern alias pcl;
using System;
using System.Text;
using System.Threading;
using Moq;
using Moq.Protected;

using IHashAlgorithm = pcl::System.Security.Cryptography.Adaptation.IHashAlgorithm;
using System.IO;

namespace Portable
{
    internal class IHashAlgorithmFactory
    {
        public static IHashAlgorithm OverrideComputeHash(Func<byte[], byte[]> action)
        {
            var mock = new Mock<IHashAlgorithm>();
            mock.Setup(a => a.ComputeHash(It.IsAny<byte[]>()))
                             .Returns(action);

            return mock.Object;
        }

        public static IHashAlgorithm OverrideComputeHash(Func<byte[], int, int, byte[]> action)
        {
            var mock = new Mock<IHashAlgorithm>();
            mock.Setup(a => a.ComputeHash(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>()))
                             .Returns(action);

            return mock.Object;
        }

        public static IHashAlgorithm OverrideComputeHash(Func<Stream, byte[]> action)
        {
            var mock = new Mock<IHashAlgorithm>();
            mock.Setup(a => a.ComputeHash(It.IsAny<Stream>()))
                             .Returns(action);

            return mock.Object;
        }
    }
}
